// export const URL = 'http://aztest.niuniuhaohan.com' // 测试站
export const URL = 'https://niuniuhaohan.cn' // 正式站

export function requst(url, prms, method, header) {

	return new Promise((resolve, reject) => {

		uni.request({
			url: `${URL}${url}`,
			data: { ...prms },
			method: method || 'GET',
			header,
			success: res => {
				resolve(res.data)
			},
			fail: err => {
				uni.showToast({ title: `${JSON.stringify(err)}`, icon: 'none' })
				reject(err)
			},
			complete: res => {
				uni.hideLoading()
				uni.stopPullDownRefresh()
				// console.log(`响应拦截器----${url}---`, res);
				if (res.statusCode == 401) { // 未登录,身份认证失败
					uni.removeStorageSync('userinfo');
					uni.redirectTo({ url: '/pages/login/login' })
				}

			}
		})

	})

}